/*
* $Date: 2010/03/04 12:20:32 $
* $Revision: 1.0 $
*/
/*
Plugin Name: Zamango Page Navigation
Plugin URI: http://www.zamango.com/
Description: This plugin adds an advanced page navigation to Wordpress
Author: Zamango
Version: 1.3
Requires at least: 2.8
Author URI: http://www.zamango.com/
License: GPL
*/
require_once('zmg_admin.php');
/******************************************************************************/
if (!class_exists('zmg_page_navigation'))
{
class zmg_page_navigation extends zmg_admin
{
var $hook = 'zmg-page-navigation';
var $version = '1.3';
var $page_title = 'Page Navigation';
var $menu_title = 'Page Navigation';
var $filename = 'zamango-page-navigation/zmg_page_navigation.php';
var $options = array();
/**********************************************************************/
function zmg_page_navigation()
{
require_once('zmg_page_navigation_defaults.php');
$this->dir_name = basename(dirname(__FILE__));
$this->plugin_url = WP_PLUGIN_URL . '/' . $this->dir_name;
$this->plugin_path = WP_PLUGIN_DIR . '/' . $this->dir_name;
$this->reg_deactivation_hook();
add_action('init', array($this, 'admin_init'), 3);
add_action('init', array($this, 'init'));
}
/**********************************************************************/
function deactivate()
{
$this->options = get_option($this->hook);
if ($this->options['clear_options']) delete_option($this->hook);
}
/**********************************************************************/
function query_vars_endpoint($vars)
{
$vars[] = 'all';
return $vars;
}
/**********************************************************************/
function add_custom_css()
{
echo '\n\n';
}
/**********************************************************************/
function init()
{
global $wp_rewrite;
$wp_rewrite->add_endpoint('all', EP_ALL);
$wp_rewrite->flush_rules();
add_filter('query_vars', array($this, 'query_vars_endpoint'));
$this->add_js('zmg-pn-admin-js', $this->plugin_url .
'/zmg_page_navigation_admin.js', true);
$this->add_css('zmg-pn-admin-js', $this->plugin_url .
'/zmg_page_navigation_admin.css', true);
if ($this->options['is_zmg_css'])
$this->add_css('zmg-pn-css', $this->plugin_url .
'/zmg_page_navigation.css');
else add_action('wp_head', array($this, 'add_custom_css'));
if ($wp_query->is_feed || is_admin()) return true;
$before_loop = new zmg_pn_parser ('before_loop', $this->options,
$this->version);
$after_loop = new zmg_pn_parser ('after_loop', $this->options,
$this->version);
if ($this->options['before_loop'])
add_action('loop_start', array($before_loop, 'parse_br'));
if ($this->options['after_loop'])
add_action('loop_end', array($after_loop, 'parse_br'));
if ($this->options['before_loop_s'])
add_action('loop_start', array($before_loop, 'parse_sp'));
if ($this->options['after_loop_s'])
add_action('loop_end', array($after_loop, 'parse_sp'));
}
/**********************************************************************/
function plugin_option_page_content()
{
if (isset($_POST['ZMG_SUBMIT']))
{
$this->validate_params();
if (isset($this->errors))
echo $this->disappearing_message(
__('Incorrect settings value', $this->hook)
);
else
{
$this->save_options();
echo $this->disappearing_message(
__('Settings have been saved', $this->hook)
);
}
}
$this->form_begin($this->hidden('ZMG_SUBMIT'));
$this->postbox($this->hook . '-blogroll_navigation',
__('Blogroll navigation', $this->hook),
$this->blogroll_navigation());
$this->postbox($this->hook . '-quick_links_on_single_post',
__('Quick links on single post', $this->hook),
$this->quick_links_on_single_post());
$this->postbox($this->hook . '-common_options_and_css',
__('Common options & CSS', $this->hook),
$this->common_options_and_css());
$this->form_end();
}
/**********************************************************************/
function blogroll_navigation()
{
$content = '
';
$content .= __('You may use the following Zamango "tags" while ' .
'configuring Page Navigation bar on lists pages',
$this->hook);
$content .= '
';
$ul = array();
$html = '[zmg_pn:current] ';
$html .= __('current page number (i.e. page on which the ' .
'navigation bar is shown)', $this->hook);
$ul[] = $this->elem($html);
$html = '[zmg_pn:total] ';
$html .= __('total pages amount', $this->hook);
$ul[] = $this->elem($html);
$html = '[zmg_pn:page] ';
$html .= __('number of page which is processing by script for ' .
'that moment (note that if page navigation bar ' .
'contains links to 10 pages plus current then value ' .
'of [zmg_pn:page] will have 11 valuessequentially)',
$this->hook);
$ul[] = $this->elem($html);
$content .= $this->ul($ul);
$content .= '
';
$content .= __('Also you can use any HTML tags.', $this->hook);
$content .= '
';
$disc_link = $this->add_description(__('Help on Zamango tags',
$this->hook), $content,
'blogroll_navigation');
$content = $this->information_message(
__('Navigation bar shown on the index, category, tag, ' .
'archive browsing, search results and other lists',
$this->hook)
);
$rows = array();
$row = array();
$html = '';
$html = __('Where the pagebar must be inserted:', $this->hook);
$row[] = $this->elem($html);
$html = $this->checkbox('before_loop', '1',
$this->options['before_loop'],
__('before posts list', $this->hook));
$html .= ' ';
$html .= $this->checkbox('after_loop', '1',
$this->options['after_loop'],
__('after posts list', $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Left part', $this->hook);
$row[] = $this->elem($html);
$html = $this->text('left', $this->options['left'],
__('Any positive number which defines amount ' .
'of links in the LEFT part of pagebar',
$this->hook));
if ($this->errors['left'])
$html .= $this->error_message(
__($this->errors['left'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Center part', $this->hook);
$row[] = $this->elem($html);
$html = $this->text('center', $this->options['center'],
__('Any odd positive number which defines ' .
'amount of links in the CENTRAL part of ' .
'pagebar. Note that if you enter even ' .
'number it will be increased by one (to ' .
'become odd one).', $this->hook));
if ($this->errors['center'])
$html .= $this->error_message(
__($this->errors['center'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Right part', $this->hook);
$row[] = $this->elem($html);
$html = $this->text('right', $this->options['right'],
__('Any positive number which defines amount ' .
'of links in the RIGHT part of pagebar',
$this->hook));
if ($this->errors['right'])
$html .= $this->error_message(
__($this->errors['right'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Separator', $this->hook);
$row[] = $this->elem($html);
$html = $this->text('separator', $this->options['separator'],
__('Text separating the central part of page ' .
'bar from the right and left ones',
$this->hook));
if ($this->errors['separator'])
$html .= $this->error_message(
__($this->errors['separator'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Link to previous page:', $this->hook);
$row[] = $this->elem($html);
$ul = array();
$ul[] = $this->elem(
$this->radio('prev_link', 'never',
$this->options['prev_link'] == 'never',
__('don\'t show', $this->hook)));
$ul[] = $this->elem(
$this->radio('prev_link', 'auto',
$this->options['prev_link'] == 'auto',
__('auto', $this->hook)));
$ul[] = $this->elem(
$this->radio('prev_link', 'always',
$this->options['prev_link'] == 'always',
__('always show', $this->hook)));
$html = $this->ul($ul, 'row');
if ($this->errors['prev_link'])
$html .= $this->error_message(
__($this->errors['prev_link'], $this->hook));
$label = __('Text of the link to previous page', $this->hook);
$label .= ' hook) . '">';
$label .= __('(Zamango tags and HTML are allowed)', $this->hook);
$label .= '';
$html .= $this->text('prev_tag', $this->options['prev_tag'],
$label);
if ($this->errors['prev_tag'])
$html .= $this->error_message(
__($this->errors['prev_tag'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Link to next page:', $this->hook);
$row[] = $this->elem($html);
$ul = array();
$ul[] = $this->elem(
$this->radio('next_link', 'never',
$this->options['next_link'] == 'never',
__('don\'t show', $this->hook)));
$ul[] = $this->elem(
$this->radio('next_link', 'auto',
$this->options['next_link'] == 'auto',
__('auto', $this->hook)));
$ul[] = $this->elem(
$this->radio('next_link', 'always',
$this->options['next_link'] == 'always',
__('always show', $this->hook)));
$html = $this->ul($ul, 'row');
if ($this->errors['next_link'])
$html .= $this->error_message(
__($this->errors['next_link'], $this->hook));
$label = __('Text of the link to next page', $this->hook);
$label .= ' hook) . '">';
$label .= __('(Zamango tags and HTML are allowed)', $this->hook);
$label .= '';
$html .= $this->text('next_tag', $this->options['next_tag'],
$label);
if ($this->errors['next_tag'])
$html .= $this->error_message(
__($this->errors['next_tag'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Link to first page:', $this->hook);
$row[] = $this->elem($html);
$label = __('Text of the link to first page', $this->hook);
$label .= ' hook) . '">';
$label .= __('(Zamango tags and HTML are allowed)', $this->hook);
$label .= '';
$html = $this->text('first_tag', $this->options['first_tag'],
$label);
if ($this->errors['first_tag'])
$html .= $this->error_message(
__($this->errors['first_tag'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Link to last page:', $this->hook);
$row[] = $this->elem($html);
$label = __('Text of the link to last page', $this->hook);
$label .= ' hook) . '">';
$label .= __('(Zamango tags and HTML are allowed)', $this->hook);
$label .= '';
$html = $this->text('last_tag', $this->options['last_tag'],
$label);
if ($this->errors['last_tag'])
$html .= $this->error_message(
__($this->errors['last_tag'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Current page sign:', $this->hook);
$row[] = $this->elem($html);
$label = __('Text defining the current page', $this->hook);
$label .= ' hook) . '">';
$label .= __('(Zamango tags and HTML are allowed)', $this->hook);
$label .= '';
$html = $this->text('curr_tag', $this->options['curr_tag'],
$label);
if ($this->errors['curr_tag'])
$html .= $this->error_message(
__($this->errors['curr_tag'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Common link text:', $this->hook);
$row[] = $this->elem($html);
$label = __('Text of the link to other page i.e. which is not ' .
'described above', $this->hook);
$label .= ' hook) . '">';
$label .= __('(Zamango tags and HTML are allowed)', $this->hook);
$label .= '';
$html = $this->text('stnd_tag', $this->options['stnd_tag'],
$label);
if ($this->errors['stnd_tag'])
$html .= $this->error_message(
__($this->errors['stnd_tag'], $this->hook));
$row[] = $this->elem($html);
$rows[] = $this->elem($row);
$row = array();
$html = __('Pop-up hints', $this->hook);
$row[] = $this->elem($html);
$html = $this->checkbox('tooltips', '1',
$this->options['tooltips'],
__('Show hints', $this->hook));
$html .= '
';
$html .= $this->text('ttip_tag', $this->options['ttip_tag'],
__('Text of on-hover hint', $this->hook));
if ($this->errors['ttip_tag'])
$html .= $this->error_message(
__($this->errors['ttip_tag'], $this->hook));
$html .= '